package com.example.demo.test.lecture.httpstest;

public class ContentBody {
    static final String CONTENT_BODY_SIGN_KEY = System.getProperty("csb.sdk.jsonbody.sign.key", "_jsonbody_sign_key_");
    private String jsonBody;
    private byte[] bytesBody;
    private com.example.demo.test.lecture.httpstest.ContentBody.Type type;

    public ContentBody(String jsonStr) {
        this.jsonBody = jsonStr;
        this.type = com.example.demo.test.lecture.httpstest.ContentBody.Type.JSON;
    }

    public ContentBody(byte[] bytes) {
        this.bytesBody = bytes;
        this.type = com.example.demo.test.lecture.httpstest.ContentBody.Type.BINARY;
    }

    public com.example.demo.test.lecture.httpstest.ContentBody.Type getContentType() {
        return this.type;
    }

    public Object getContentBody() {
        return this.type == com.example.demo.test.lecture.httpstest.ContentBody.Type.BINARY ? this.bytesBody : this.jsonBody;
    }

    public static enum Type {
        JSON("application/json"),
        BINARY("application/octet-stream");

        private String ct;

        private Type(String ct) {
            this.ct = ct;
        }

        public String getContentType() {
            return this.ct;
        }
    }
}
